<?php
$clearfix = '';
$name = $block['#name'];
$nowrap = $name=='middle'?1:intval ($block['#no-wrap']); //no wrap in case generate
$nomain = intval ($block['#no-main']);
if (isset ($block['#parent'])&& $block['#parent'] == 'middle') $nomain = 1;
$wrapinner = intval ($block['#wrap-inner']);
$maininner = intval ($block['#main-inner']);
?>
<?php if (!$nowrap): 

if (!$wrapinner && $nomain && !$maininner) $clearfix = ' clearfix';
?>
<div id="ja-<?php echo $name ?>" class="wrap<?php echo $clearfix ?>">		
<?php endif ?>

<?php if ($wrapinner):
for ($i=1;$i<=$wrapinner;$i++):
if ($nomain && !$maininner && $i==$wrapinner) $clearfix = ' clearfix';
?> 
	<div class="wrap-inner<?php echo $i.$clearfix ?>">
<?php endfor; 
endif ?>

<?php if (!$nomain): 
if (!$maininner) $clearfix = ' clearfix';
?>
	<div class="main<?php echo $clearfix ?>">
<?php endif ?>

<?php
//gen special begin markup (markup=1/2/3)
//1: basic - nothing; 2: advanced - left & right ; 3: complex - top - middle -bottom
$markup = intval ($block['#markup']);
switch ($markup) {
	case 2:
		?>
		<div class="l"></div>
		<div class="main-inner clearfix">
		<?php
		break;
	case 3:
		?>
		<div class="top"><div class="tl"></div><div class="tr"></div></div>
		<div class="mid clearfix"><div class="ml"></div>
		<div class="main-inner clearfix">
		<?php
		break;
	case 1:
	default:
		break;
}
?>

<?php if ($maininner):
for ($i=1;$i<=$maininner;$i++):
if ($i==$maininner) $clearfix = ' clearfix';
?> 
	<div class="main-inner<?php echo $i.$clearfix ?>">
<?php endfor; 
endif;
?>

{content}

<?php if ($maininner):
for ($i=1;$i<=$maininner;$i++):
?> 
	</div>
<?php endfor; 
endif; ?> 

<?php 		
//gen special end markup (markup=1/2/3)
//1: basic - nothing; 2: advanced - left & right ; 3: complex - top - middle -bottom
$markup = intval ($block['#markup']);
switch ($markup) {
	case 2:
		?>
		</div> <?php //for inner ?>
		<div class="r"></div>
		<?php
		break;
	case 3:
		?>
		</div> <?php //for inner ?>
		<div class="mr"></div></div> <?php //for mid ?>
		<div class="bot"><div class="bl"></div><div class="br"></div></div>
		<?php
		break;
	case 1:
	default:
		break;
}
?>

<?php if (!$nomain): ?>
	</div>
<?php endif ?>

<?php if ($wrapinner):
for ($i=1;$i<=$wrapinner;$i++):
?> 
	</div>
<?php endfor; 
endif ?>

<?php if (!$nowrap): ?>
</div>		
<?php endif; ?>